<?php
// +----------------------------------------------------------------------
// | Qbt CMS Plugin
// +----------------------------------------------------------------------
// | Copyright (c) 2012-2018 http://www.qbt8.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 黄老邪 <develop02@qbt8.com>
// +----------------------------------------------------------------------
namespace plugins\qbt_guestbook;
use cmf\lib\Plugin;
use think\Config;
use think\db;

class QbtGuestbookPlugin extends Plugin
{

    public $info = [
        'name'        => 'QbtGuestbook',
        'title'       => '留言板',
        'description' => '千佰特留言板应用',
        'status'      => 1,
        'author'      => '千佰特',
        'version'     => '1.0',
        'demo_url'    => 'http://www.qbt8.com',
        'author_url'  => 'http://www.qbt8.com'
    ];

    public $hasAdmin = 1;//插件是否有后台管理界面

    // 插件安装
    public function install()
    {
        $config = Config::get('database');
        Db::query("
            CREATE TABLE IF NOT EXISTS `{$config['prefix']}guestbook` (
            `id`  int NOT NULL AUTO_INCREMENT,
            `name`  varchar(100) NULL DEFAULT '' COMMENT '名字' ,
            `email`  varchar(100) NULL DEFAULT '' COMMENT '邮箱' ,
            `tel`  varchar(100) NULL DEFAULT '' COMMENT '电话' ,
            `content`  text NULL COMMENT '内容' ,
            `addtime`  int NULL COMMENT '添加时间' ,
            PRIMARY KEY (`id`)
            )
        ");
        return true;
    }

    // 插件卸载
    public function uninstall()
    {
        $config = Config::get('database');
        Db::query("DROP TABLE `{$config['prefix']}guestbook`");
        return true;
    }


}